package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.BookInOrder;
import com.pgybook.db.entity.domain.BookInOrderEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface BookInOrderMapper {
    int countByExample(BookInOrderEx example);

    int deleteByExample(BookInOrderEx example);

    @Delete({
            "delete from bookinorder",
            "where BOOKINORDERID = #{bookinorderid,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long bookinorderid);

    @Insert({
            "insert into bookinorder (INSTANCEID, ORDERID, ",
            "BOOKNAME, STATUS, ",
            "CRTTIME, REACHCUSTTIME, ",
            "RETURNTIME, SENDSTAFF, ",
            "RETURNSTAFF, UPTTIME)",
            "values (#{instanceid,jdbcType=BIGINT}, #{orderid,jdbcType=BIGINT}, ",
            "#{bookname,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, ",
            "#{crttime,jdbcType=TIMESTAMP}, #{reachcusttime,jdbcType=TIMESTAMP}, ",
            "#{returntime,jdbcType=TIMESTAMP}, #{sendstaff,jdbcType=INTEGER}, ",
            "#{returnstaff,jdbcType=INTEGER}, #{upttime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "bookinorderid", before = false, resultType = Long.class)
    int insert(BookInOrder record);

    int insertSelective(BookInOrder record);

    List<BookInOrder> selectByExample(BookInOrderEx example);

    @Select({
            "select",
            "BOOKINORDERID, INSTANCEID, ORDERID, BOOKNAME, STATUS, CRTTIME, REACHCUSTTIME, ",
            "RETURNTIME, SENDSTAFF, RETURNSTAFF, UPTTIME",
            "from bookinorder",
            "where BOOKINORDERID = #{bookinorderid,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    BookInOrder selectByPrimaryKey(Long bookinorderid);

    int updateByExampleSelective(@Param("record") BookInOrder record, @Param("example") BookInOrderEx example);

    int updateByExample(@Param("record") BookInOrder record, @Param("example") BookInOrderEx example);

    int updateByPrimaryKeySelective(BookInOrder record);

    @Update({
            "update bookinorder",
            "set INSTANCEID = #{instanceid,jdbcType=BIGINT},",
            "ORDERID = #{orderid,jdbcType=BIGINT},",
            "BOOKNAME = #{bookname,jdbcType=VARCHAR},",
            "STATUS = #{status,jdbcType=INTEGER},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP},",
            "REACHCUSTTIME = #{reachcusttime,jdbcType=TIMESTAMP},",
            "RETURNTIME = #{returntime,jdbcType=TIMESTAMP},",
            "SENDSTAFF = #{sendstaff,jdbcType=INTEGER},",
            "RETURNSTAFF = #{returnstaff,jdbcType=INTEGER},",
            "UPTTIME = #{upttime,jdbcType=TIMESTAMP}",
            "where BOOKINORDERID = #{bookinorderid,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(BookInOrder record);
}
